﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;
using System.Data;

namespace Directory.DAL
{
	internal sealed class DALHelper
	{

		public static string GetNullableString(SqlDataReader reader, int col)
		{
			if (!reader.IsDBNull(col))
			{
				return reader.GetString(col);
			}
			return null;
		}

		public static int GetReturnValue(SqlCommand cmd)
		{
			foreach (SqlParameter parameter in cmd.Parameters)
			{
				if (((parameter.Direction == ParameterDirection.ReturnValue) && (parameter.Value != null)) && (parameter.Value is int))
				{
					return (int)parameter.Value;
				}
			}
			return -1;
		}
	}
}
